<template>
  <div class="g-wrap" v-if="songDetail">
    <div class="warp-23">
      <div class="u-cover-rank">
        <img :src="songDetail.al.picUrl" alt="" v-if="songDetail.al">
        <span class="msk"></span>

      </div>
      <div class="out-list">
        <i class="u-icn"></i>
        <a href="#">生成外链播放器</a>
      </div>
    </div>
    <div class="m-info">
      <div class="hd">
        <i class="hd-icon-song-list"></i>
        <h2>{{ songDetail.name }}</h2>
      </div>
      <div class="user">
        <span class="name" v-if="songDetail.ar">
          歌手：
          <router-link :to="{name:'Work',params: {id:n.id}}"
                       :title="n.name"
                       v-for="(n,m) in songDetail.ar" :key="m"
          >{{ n.name }}<span v-if="m!=songDetail.ar.length-1" style="display: inline;"> / </span>
          </router-link>
        </span>
        <span style="color: #666;">所属专辑：<router-link :to="{name:'AlbumDetail',params:{id:songDetail.al.id}}" style="
color: #0c73c2;" v-if="songDetail.al"> {{ songDetail.al.name }}</router-link></span>
      </div>
      <div class="btns">
        <a href="javascript:;" class="ply" @click.prevent="sentSongUrl(songDetail)">
          <i class="ply">
            <em class="ply"></em>
            播放
          </i>
        </a>
        <a href="javascript:;" class="ply" @click.prevent="addList(songDetail)"></a>
        <a href="javascript:;">
          <i class="ply">收藏</i>
        </a>
        <a href="javascript:;">
          <i class="ply">分享</i>
        </a>
        <a href="javascript:;">
          <i class="ply">下载</i>
        </a>
        <a href="javascript:;">
          <i class="ply">({{ total }})</i>
        </a>
      </div>

      <div class="lyric-content" v-if="isShow">
        <p v-for="(item,index) in songLyric.slice(0,13)" :key="index">{{ item.lyric }}</p>
      </div>
      <div class="lyric-content" v-else>
        <p v-for="(item,index) in songLyric" :key="index">{{ item.lyric }}</p>
      </div>

      <div class="f-cb">
        <a href="javascript:;" class="zhankai" v-if="isShow" @click="changeShow('up')">展开</a>
        <a href="javascript:;" class="zhankai" v-else @click="changeShow('down')">收起</a>
        <i :class="u_icn"></i>
      </div>
      <div class="user-operation">
        <p>
          <a href="#">报错</a>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import {formatDate} from '@/utils/formatDate'
import {mapState} from "vuex";

export default {
  name: "index",
  data() {
    return {
      formatDate: formatDate,
      isShow: true,
      u_icn: 'u-icn-down',
      total: ''
    }
  },
  methods: {
    addList(i) {
      this.$store.commit('track/ADDMUSICLIST', i)
    },
    sentSongUrl(i) {
      this.$store.commit('track/SETMUSIC', i)
    },
    async getComment() {
      let result = await this.$API.reqSongCommentHot(this.$route.params.id);
      this.total = result.data.total;
    },
    changeShow(str) {
      this.isShow = !this.isShow
      if (str === 'up') {
        this.u_icn = 'u-icn-up'
      } else {
        this.u_icn = 'u-icn-down'
      }
    }
  },
  computed: {
    ...mapState('songDetailList', ['lyricList', 'songLyric'])
  },
  props: ['songDetail'],
  mounted() {
    this.getComment()
  }
}
</script>

<style scoped lang="less">
.g-wrap {
  width: 640px;
  margin: 0 auto;
  padding-top: 40px;

  .warp-23 {
    float: left;
    width: 206px;
    height: 234px;
    margin-right: -226px;

    .out-list {
      width: 100px;
      height: 16px;
      float: right;
      display: flex;
      margin-right: 55px;
      align-items: center;
      margin-top: 20px;

      .u-icn {
        width: 16px;
        height: 16px;
        display: inline-block;
        background-image: url("../../../assets/icon.png");
        background-position: -34px -863px;
      }

      a {
        color: #4996d1;
        text-decoration: underline;
      }
    }

    .u-cover-rank {
      width: 198px;
      height: 198px;
      float: left;
      position: relative;

      .msk {
        width: 206px;
        height: 205px;
        top: -4px;
        left: -4px;
        background-position: -140px -580px;
        background-image: url("../../../assets/coverall.png");
      }

      img {
        width: 130px;
        height: 130px;
        margin: 34px;
      }

      span {
        position: absolute;
        top: 3px;
        left: 3px;
        width: 208px;
        height: 208px;
        background: url("../../../assets/coverall.png") no-repeat -230px -380px;
      }
    }
  }


  .m-info {
    width: 485px;
    //margin-top: 20px;
    margin-left: 225px;

    .hd {

      margin-bottom: 10px;
      display: flex;
      justify-items: center;
      //align-items: center;

      .hd-icon-song-list {
        display: inline-block;
        margin-right: 10px;
        width: 54px;
        height: 24px;
        overflow: hidden;
        vertical-align: middle;
        background: url("../../../assets/icon.png") no-repeat 0 -463px;
      }

      h2 {
        font-size: 24px;
        font-weight: 500;
        font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
        margin-top: -5px;
      }
    }

    .user {
      width: 410px;
      height: 35px;
      margin-top: 20px;

      .name {
        color: #666;

        a {
          color: #0c73c2;
        }
      }

      span {
        margin-top: 10px;
        display: block;
      }

      .day {
        color: #666;
      }

      .user-img {
        width: 35px;
        height: 35px;
        vertical-align: center;
      }

      .user-icon {
        width: 13px;
        height: 13px;
      }
    }

    .user-operation {
      text-align: right;
      margin-top: 48px;
      line-height: 30px;

      p {
        a {
          color: #999;
          text-decoration: underline;
        }
      }
    }

    .f-cb {
      width: 100%;
      text-align: left;
      margin-top: 10px;

      .zhankai {
        color: #0c73c2;
      }

      .u-icn-down {
        display: inline-block;
        width: 11px;
        height: 8px;
        background: url("../../../assets/icon.png") no-repeat -65px -520px;
      }

      .u-icn-up {
        display: inline-block;
        width: 11px;
        height: 8px;
        background: url("../../../assets/icon.png") no-repeat -45px -520px;
      }
    }

    .lyric-content {
      margin-top: 35px;
      line-height: 23px;
    }

    .btns {
      width: 483px;
      height: 31px;
      margin-top: 20px;

      .ply {
        background-repeat: no-repeat;
        background-image: url("../../../assets/button2.png");
      }

      a {
        display: inline-block;
        float: left;

        i {
          margin-right: 5px;
          font-family: simsun, \5b8b\4f53;
          color: #666;
        }

        &:nth-child(1) {

          background-position: right -428px;

          i {
            padding: 0 10px 0 8px;
            display: inline-block;
            *display: inline;
            *zoom: 1;
            height: 31px;
            line-height: 31px;
            overflow: hidden;
            *line-height: 32px;
            vertical-align: top;
            text-align: center;
            cursor: pointer;
            color: #fff;
            background-position: 0 -387px;

            em {
              float: left;
              width: 20px;
              height: 18px;
              margin: 6px 2px 2px 0;
              background-position: 0 -1622px;
            }
          }
        }

        &:nth-child(2) {
          margin-right: 5px;
          width: 31px;
          height: 31px;
          margin-left: -3px;
          padding-right: 0;
          background-position: 0 -1588px;
        }

        &:nth-child(3) {
          i {
            background-position: 0 -977px;
            float: left;
            height: 31px;
            line-height: 31px;
            min-width: 23px;
            cursor: pointer;
            padding: 0 7px 0 28px;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
            border-right: 1px solid #C3C3C3;
          }
        }

        &:nth-child(4) {
          i {
            background-position: 0 -1225px;
            float: left;
            height: 31px;
            line-height: 30px;
            min-width: 23px;
            cursor: pointer;
            padding: 0 7px 0 28px;
            border-right: 1px solid #C3C3C3;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
          }
        }

        &:nth-child(5) {
          i {
            background-position: 0 -2761px;
            float: left;
            height: 31px;
            line-height: 30px;
            min-width: 23px;
            cursor: pointer;
            padding: 0 10px 0 28px;
            border-right: 1px solid #C3C3C3;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
          }
        }

        &:nth-child(6) {
          i {
            background-position: 0 -1465px;
            float: left;
            height: 31px;
            line-height: 30px;
            min-width: 23px;
            cursor: pointer;
            padding: 0 10px 0 28px;
            border-right: 1px solid #C3C3C3;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
          }
        }
      }
    }


  }

  .desc-more {
    display: block;
    margin-top: 50px;
    line-height: 24px;
    font-size: 12px;
    color: #666;

    b {
      font-weight: bold;
      color: #333;
    }
  }

  .album-desc-dot {
    display: block;
    margin-top: 50px;
    line-height: 24px;
    font-size: 12px;
    color: #666;
    //width: 410px;
    //height: 180px;
    b {
      font-weight: bold;
      color: #333;
    }
  }

  .f-cb {
    width: 100%;
    text-align: right;

    .zhankai {
      color: #0c73c2;
    }

    .u-icn-down {
      display: inline-block;
      width: 11px;
      height: 8px;
      background: url("../../../assets/icon.png") no-repeat -65px -520px;
    }

    .u-icn-up {
      display: inline-block;
      width: 11px;
      height: 8px;
      background: url("../../../assets/icon.png") no-repeat -45px -520px;
    }
  }
}
</style>